!function(){"use strict";class e{constructor(e){let t={root:null,rootMargin:"600px 0px 600px 0px",threshold:this.buildThresholdList(),classTarget:this};this.observer=new IntersectionObserver(e,t)}addToObserver(e){this.observer.observe(e)}removeFromObserver(e){this.observer.unobserve(e)}buildThresholdList(){return[0,.1,.25,.5,.75,1]}}function t(e){if(!e||!e.endsWith("%"))return.5;const t=parseFloat(e);return t<=5?0:t>=95?1:.5}function a(e){const a=e.getBoundingClientRect(),r=Math.round(a.width),i=e.attributes.width,s=e.attributes.height,o=i?i.value:"auto",c=s?s.value:"auto";let l=Math.round(a.height);!l>0&&(l=r>0&&o>0&&c>0?Math.round(parseInt(c)/parseInt(o)*r):"auto");let n={width:r,height:l};const d=e.dataset.optSrc||!1;let h=!1;if(d&&!d.includes("/rt:"))try{const a=window.getComputedStyle(e);if("cover"===a.objectFit&&"auto"!==l&&e.naturalWidth&&e.naturalHeight){Math.abs(e.naturalWidth/e.naturalHeight-r/l)>.01&&(h=function(e){if(!e)return null;const a=e.trim().split(/\s+/),r=t(a[0]),i=t(a[1]);return.5===r&&.5===i?null:[r,i]}(a.objectPosition)||!0)}}catch(e){h=!1}return n.crop=h,n}function r(e,t){if(e.width<=t.width&&e.height<=t.height)return e;const a=Math.min(t.width/e.width,t.height/e.height);return a<1&&(e.width=Math.round(e.width*a),e.height=Math.round(e.height*a)),e}function i(e,t){return Object.keys(t).forEach((function(a){e[a]=t[a]})),e}let s=new class{constructor(){this.serviceDomain=".i.optimole.com",this.serviceData={key:"undefined",quality:"auto",network_optimizations:!1,backgroundReplaceClasses:[],backgroundLazySelectors:"",watchClasses:[],lazyloadOnly:"",scalingDisabled:!1,ignoreDpr:!0,customDomain:!1,maxWidth:0,maxHeight:0},"undefined"!=typeof optimoleData&&optimoleData===Object(optimoleData)&&(this.serviceData=i(this.serviceData,optimoleData)),this.hasSizeLimit=Number.isInteger(this.serviceData.maxWidth)&&Number.isInteger(this.serviceData.maxHeight)&&this.serviceData.maxWidth>0&&this.serviceData.maxHeight>0,this.aTag=null}_cdnKey(){return this.serviceData.key.toLowerCase()}getAbsoluteUrl(e){return null===this.aTag&&(this.aTag=document.createElement("a")),this.aTag.href=e,this.aTag.href}getImageCDNUrl(e,t){const a=void 0!==this.serviceData.customDomain&&!1!==this.serviceData.customDomain;if(e.includes(this.serviceDomain)||a&&e.includes(this.serviceData.customDomain))return e;const i=this._cdnKey();if(("undefined"===i||""===i)&&!a)return e;if(-1===(e=this.getAbsoluteUrl(e)).indexOf("://"))return e;const s=a?"https://"+this.serviceData.customDomain:"https://"+i+this.serviceDomain;let o=t.width,c=t.height;if(o="auto"===o?this.hasSizeLimit?this.serviceData.maxWidth:"auto":Math.round(o),c="auto"===c?this.hasSizeLimit?this.serviceData.maxHeight:"auto":Math.round(c),this.hasSizeLimit&&"auto"!==o&&"auto"!==c){const e=r({width:o,height:c},{width:this.serviceData.maxWidth,height:this.serviceData.maxHeight});o=e.width,c=e.height}const l=[s,"w:"+o,"h:"+c,"q:"+("eco"===t.quality?"eco":this.serviceData.quality)],n=Math.max("auto"===o?0:o,"auto"===c?0:c);window.devicePixelRatio>1&&(!this.serviceData.ignoreDpr||n<150)&&l.push("dpr:"+window.devicePixelRatio.toFixed(1)),!0===t.crop?l.push("rt:fill"):Array.isArray(t.crop)&&(l.push("rt:fill"),l.push("g:fp:"+t.crop[0]+":"+t.crop[1])),l.push(e);return l.join("/")}requiresBetterQuality(e){if(void 0===e.dataset.optOptimizedWidth||void 0===e.dataset.optOptimizedHeight)return!0;const t=parseInt(e.dataset.optOptimizedWidth),a=parseInt(e.dataset.optOptimizedHeight),r=parseInt(e.clientWidth),i=parseInt(e.clientHeight),s=Math.abs(t-r),o=Math.abs(a-i);return s>10||o>10}transformURL(e,t){const a=e.indexOf("://");if(-1===a)return e;const r=e.substring(0,a),i=e.substring(a+3);if("http"!==r&&"https"!==r||!i)return e;const s=navigator.connection||navigator.mozConnection||navigator.webkitConnection,o=s?s.effectiveType:"",c=(!1===this.serviceData.ignoreDpr||Math.max(t.width,t.height)<150)&&window.devicePixelRatio>1&&-1===e.indexOf("/dpr:");let l=!1,n=e.replace(/(w|h|q):([0-9.]+|mauto|auto|eco)/g,((e,a,r)=>{let i;if("w"===a)i=this.sizeSafe(this.sizeForConnection(o,t.width));else if("h"===a)i=this.sizeSafe(this.sizeForConnection(o,t.height));else{const e=void 0!==t.quality&&t.quality!==r?t.quality:r;i=this.qualityForConnection(o,e),c&&!l&&(i+="/dpr:"+window.devicePixelRatio.toFixed(1),l=!0)}return a+":"+i}));return!0===t.crop?n=n.replace("/w:","/rt:fill/w:"):Array.isArray(t.crop)&&(n=n.replace("/w:","/rt:fill/g:fp:"+t.crop[0]+":"+t.crop[1]+"/w:")),n}sizeSafe(e){return null===e||"undefined"===e||"0"===e||0===e||isNaN(e)?"auto":e}qualityForConnection(e,t){if(!0!==this.serviceData.network_optimizations)return t;let a;switch(e){case"4g":case"3g":default:a=t;break;case"2g":case"slow-2g":a="45"}return a}sizeForConnection(e,t){if(!0!==this.serviceData.network_optimizations)return t;let a=window.devicePixelRatio;switch(e){case"3g":case"2g":case"slow-2g":return Math.round(t/a);default:return t}}getCDNForImage(e,t){let r=a(e);return r=i(r,t),{url:this.transformURL(this.getImageCDNUrl(e.dataset.optSrc,r),r),size:r}}},o=new class{constructor(e=null){this.replacerService=e,this.loadEarlyClass="optimole-load-early"}onlyLazyload(e){return void 0!==this.replacerService.serviceData.scalingDisabled&&!0===this.replacerService.serviceData.scalingDisabled||(!(!e.classList||!e.classList.contains(this.loadEarlyClass))||""!==this.replacerService.serviceData.lazyloadOnly&&e.classList.contains(this.replacerService.serviceData.lazyloadOnly))}requiresBetterQuality(e){return null===this.replacerService||"undefined"===this.replacerService||this.replacerService.requiresBetterQuality(e)}getImageSrc(e,t={}){let s=a(e);return this.replacerService.hasSizeLimit&&(s=r(s,{height:this.replacerService.serviceData.maxHeight,width:this.replacerService.serviceData.maxWidth})),s=i(s,t),Math.abs(e.naturalWidth-s.width)<50&&Math.abs(e.naturalHeight-s.height)<50&&(s={width:e.naturalWidth,height:e.naturalHeight}),null!==this.replacerService&&"undefined"!==this.replacerService?this.onlyLazyload(e)?{url:e.dataset.optSrc,size:s}:this.replacerService.getCDNForImage(e,s):"undefined"!==t&&"undefined"!==t.quality&&"eco"===t.quality?{url:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",size:s}:{url:e.dataset.optSrc,size:s}}prepareImage(e,t,a=null){let r=e.target;if((void 0===r.src||""===r.src)&&r.dataset.optSrc){let e={quality:"eco"},t=this.getImageSrc(r,e);r.src=t.url}t.addToObserver(r),a&&a.addToObserver(r)}prepareEmbeddedVideo(e,t){let a=e.target;t.addToObserver(a)}skipLazyLoad(e){let t=e.target;if("IFRAME"===t.tagName&&t.dataset.optSrc)return t.src=t.dataset.optSrc,void(t.dataset.optLazyLoaded="true");if(t.dataset.optSrc){let e=this.getImageSrc(t);t.src=e.url,t.dataset.optLazyLoaded="true"}}lazyLoadImage(e){let t=e.target;if(void 0!==t.dataset.optSrc&&this.requiresBetterQuality(t)&&"true"!==t.dataset.optLazyLoaded){let e=this.getImageSrc(t),a=e.url,r=new Image;t.classList.add("optml_lazyload_img");let i=this;r.onload=async function(){this.complete&&(t.src=this.src,t.dataset.optLazyLoaded="true",null!==i.replacerService.serviceData&&!1===i.replacerService.serviceData.ignoreDpr&&window.devicePixelRatio>1&&(!i.onlyLazyload(t)&&"auto"!==e.size.width&&e.size.width>0&&(void 0!==t.style.maxWidth&&""!==t.style.maxWidth||"undefined"!==getComputedStyle(t).maxWidth&&""!==getComputedStyle(t).maxWidth||(t.style.maxWidth=e.size.width+"px")),!t.width&&!t.height&&!t.classList.contains(i.replacerService.serviceData.lazyloadOnly)&&"auto"!==e.size.width&&"auto"!==e.size.height&&e.size.width>0&&e.size.height>0&&(t.width=""+e.size.width,t.height=""+e.size.height)),t.dataset.optOptimizedWidth=""+e.size.width,t.dataset.optOptimizedHeight=""+e.size.height,t.dataset.optLazyLoaded="true",t.classList.remove("optml_lazyload_img"))};let s=t.parentNode;if(s&&/^picture$/i.test(s.nodeName||""))for(let e of s.getElementsByTagName("source"))if(e.srcset===t.currentSrc)return void(r.src=t.currentSrc);r.src=a}else if(null!==this.replacerService&&void 0!==this.replacerService){if("true"!==t.dataset.optLazyLoaded&&this.replacerService.serviceData.watchClasses.length>0)for(let e=0;e0)for(let e=0;e0){if(void 0===e.classList||0===e.classList.length)return!1;for(let t=0;t